package com.kgc.ssm.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kgc.ssm.entity.dto.QuoSearchParam;
import com.kgc.ssm.entity.dto.QuotationMaintenance;
import com.kgc.ssm.entity.dto.Result;
import com.kgc.ssm.mapper.QuotationMaintenanceMapper;
import com.kgc.ssm.service.QuotationMaintenanceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class QuotationMaintenanceServiceImpl implements QuotationMaintenanceService {
    @Resource
    private QuotationMaintenanceMapper quotationMaintenanceMapper;

    @Override
    public Result<List<QuotationMaintenance>> selectQuotationMaintenance(QuoSearchParam param) {
        // 打印查询参数
        System.out.println("后端接收到的查询参数: " + param);

        // 使用 PageHelper 进行分页
        PageHelper.startPage(param.getPageNum(), param.getPageSize());

        // 查询数据
        List<QuotationMaintenance> pageList  = quotationMaintenanceMapper.selectQuotationMaintenance(param);
        PageInfo<QuotationMaintenance> pageInfo = new PageInfo<>(pageList);
        // 打印查询结果
        System.out.println("查询结果0: " + pageInfo);

        // 返回分页结果
        return new Result<>("查询成功", 200, pageInfo.getList(), pageInfo.getTotal());
    }
}